function dynamicLoadCss(url) {
  var head = document.getElementsByTagName('head')[0];
  var link = document.createElement('link');
  link.type='text/css';
  link.rel = 'stylesheet';
  link.href = url;
  head.appendChild(link);
}

if (location.protocol === 'http:' && location.hostname !== 'localhost')
  location.protocol = 'https:';
if ('paintWorklet' in CSS) {
  dynamicLoadCss('./index.css')
  CSS.paintWorklet.addModule('paint.js')
} else {
  document.body.innerHTML =
    'You need support for <a href="https://drafts.css-houdini.org/css-paint-api/">CSS Paint API</a> to view this demo :(';
}
